package com.xmh.reverseproxy.config;

import lombok.extern.slf4j.Slf4j;
import org.apache.http.client.utils.URIUtils;
import org.mitre.dsmiley.httpproxy.ProxyServlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

@Slf4j
public class DiskProxyServlet /*extends ProxyServlet*/ {


//    @Override
//    protected void service(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws ServletException, IOException {
//        String targetUri = "https://www.baidu.com/";
//
//        servletRequest.setAttribute(ATTR_TARGET_URI, null);
//        super.targetUri = targetUri;
//
//        URI uri = null;
//        try {
//            uri = new URI(targetUri);
//        } catch (URISyntaxException e) {
//            log.error("创建URI对象出错, targetUri[{}]", targetUri, e);
//        }
//        servletRequest.setAttribute(ATTR_TARGET_HOST, null);
//        super.targetHost = URIUtils.extractHost(uri);
//
//        super.service(servletRequest, servletResponse);
//
//    }

}
